/// 商店信息模型
class Shop {
  final int shopId;           // 商店ID
  final String shopName;      // 商店名称
  final String shopAddress;   // 商店地址
  final String? shopPhone;    // 商店电话
  final String? businessHours; // 营业时间
  final double? rating;       // 评分
  final double? distance;     // 距离（公里）
  final String? shopImage;    // 商店图片
  final List<String>? shopImages; // 商店图片列表
  final String? description;  // 商店描述
  final List<String>? tags;   // 商店标签
  final String? category;     // 商店分类
  final bool? isOpen;         // 是否营业中

  Shop({
    required this.shopId,
    required this.shopName,
    required this.shopAddress,
    this.shopPhone,
    this.businessHours,
    this.rating,
    this.distance,
    this.shopImage,
    this.shopImages,
    this.description,
    this.tags,
    this.category,
    this.isOpen,
  });

  Map<String, dynamic> toJson() {
    return {
      'shop_id': shopId,
      'shop_name': shopName,
      'shop_address': shopAddress,
      if (shopPhone != null) 'shop_phone': shopPhone,
      if (businessHours != null) 'business_hours': businessHours,
      if (rating != null) 'rating': rating,
      if (distance != null) 'distance': distance,
      if (shopImage != null) 'shop_image': shopImage,
      if (shopImages != null) 'shop_images': shopImages,
      if (description != null) 'description': description,
      if (tags != null) 'tags': tags,
      if (category != null) 'category': category,
      if (isOpen != null) 'is_open': isOpen,
    };
  }

  factory Shop.fromJson(Map<String, dynamic> json) {
    return Shop(
      shopId: json['shop_id'] as int,
      shopName: json['shop_name'] as String,
      shopAddress: json['shop_address'] as String,
      shopPhone: json['shop_phone'] as String?,
      businessHours: json['business_hours'] as String?,
      rating: json['rating'] != null ? (json['rating'] as num).toDouble() : null,
      distance: json['distance'] != null ? (json['distance'] as num).toDouble() : null,
      shopImage: json['shop_image'] as String?,
      shopImages: json['shop_images'] != null ? List<String>.from(json['shop_images']) : null,
      description: json['description'] as String?,
      tags: json['tags'] != null ? List<String>.from(json['tags']) : null,
      category: json['category'] as String?,
      isOpen: json['is_open'] as bool?,
    );
  }

  @override
  String toString() {
    return 'Shop(shopId: $shopId, shopName: $shopName, shopAddress: $shopAddress, rating: $rating, distance: $distance)';
  }
}
